package cn.szabadsag.hrm.client;

import cn.szabadsag.hrm.doc.CourseDoc;
import cn.szabadsag.hrm.util.AjaxResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @author yangcong
 * @date 2022年04月11日 9:45
 * @since
 */
@Component
public class SearchServiceClientFallbackFactory implements FallbackFactory<SearchServiceClient> {

    /**
     * 熔断降级
     * @param throwable
     * @return
     */
    @Override
    public SearchServiceClient create(Throwable throwable) {
        return new SearchServiceClient() {
            @Override
            public AjaxResult add(CourseDoc doc) {
                System.out.println("熔断降级！！！！");
                throwable.printStackTrace();
                return AjaxResult.me().setSuccess(false).setMessage("上线失败！");
            }

            @Override
            public AjaxResult delete(Long id) {
                throwable.printStackTrace();
                return AjaxResult.me().setSuccess(false).setMessage("下线失败！");
            }
        };
    }
}
